package com.xu.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xu.mapper.CollegeMapper;
import com.xu.pojo.College;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollegeServiceImpl implements CollegeService{

    @Autowired
    private CollegeMapper collegeMapper;

    @Override
    public College queryCollegeById(int collegeId) {
        return collegeMapper.queryCollegeById(collegeId);
    }

    @Override
    public List<College> queryAllCollege() {
        return collegeMapper.queryAllCollege();
    }

    @Override
    public List<College> queryAllCollegeExceptOffice() {
        List<College> colleges = collegeMapper.queryAllCollege();
        colleges.remove(collegeMapper.queryCollegeById(1));
        return colleges;
    }

    @Override
    public PageInfo<College> queryAllCollegePaging(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<College> lists = collegeMapper.queryAllCollege();
        PageInfo<College> pageInfo = new PageInfo<College>(lists);
        return pageInfo;
    }
}
